import React,{useMemo} from 'react';
import { Space, Table, Tag,Button,Select,Popconfirm } from 'antd';
import dayjs from 'dayjs';
import {useSelector,useDispatch} from "react-redux"
const Typelist = () => {
  let obj=useSelector(state=>state.todos)
let newlist=  useMemo(()=>{
return    obj.shoplist.filter(item=>{
      return item.state
    })
  },[obj.shoplist])
    const columns = [
  {
    title: '优惠卷名称',
    dataIndex: 'title',
  
  },
  {
    title: '优惠卷面值',
    dataIndex: 'mian',

  },
  {
    title: '优惠卷最低消费',
    dataIndex: 'min',

  },
  {
    title: '优惠卷有效期限',
    dataIndex: 'day',

  },
    {
    title: '排序',
    dataIndex: 'sort',

  },
      {
    title: '状态',
    dataIndex: 'state',
    render:(state)=>{
      return <Tag color={state?"blue":"red"}>{state?"开启":'关闭'}</Tag>
    }

  },
     {
    title: '创建时间',
    dataIndex: 'time',
    render:(time)=>{
      return dayjs(time).format('YYYY-MM-DD HH:mm:ss');
    }

  },
  {
    title: 'Action',
    key: 'action',
    render: (_, record) => (
      <Space size="middle">
           
<Button>编辑</Button>
<Button>删除</Button>
<Popconfirm
    title="Delete the task"
    description="Are you sure to delete this task?"
    onConfirm={()=>{
      dispatch(async_del(record.id))
    }}
    onCancel={()=>{

    }}
    okText="Yes"
    cancelText="No"
  >
 
  </Popconfirm>
      </Space>
    ),
  },
];
return <div>
  <Table columns={columns} dataSource={newlist} rowKey={'id'}/>;
</div>
}

export default Typelist;